package com.itwn.comic.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itwn.comic.entity.Page;
import com.itwn.comic.mapper.PageMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PageService {
    @Autowired
    PageMapper pageMapper;

    public PageInfo<Page> queryPageBySectionId(Integer size, Integer now, Integer id) {

        PageHelper.startPage(now,size);
        List<Page> list= pageMapper.selectPageBYSectionId(id);
        return new PageInfo<>(list);
    }

    public int addPage(Page page) {
        return pageMapper.insert(page);
    }

    public int modifyPage(Page page) {
        return pageMapper.updateByPrimaryKey(page);
    }

    public int removePageById(int id) {
        return pageMapper.deleteByPrimaryKey(id);
    }

    public int queryRidBySid(Integer sid) {
        return pageMapper.selectRidBySid(sid);
    }
}
